﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Ordonnance
{
    public partial class FormAddGame : Form
    {

        public delegate bool TryConfirmDelegate(string Val);
        TryConfirmDelegate TryConfirm;

        public FormAddGame()
        {
            InitializeComponent();
        }

        public void ShowDialog(TryConfirmDelegate TryConfirm)
        {
            this.TryConfirm = TryConfirm;
            txbValue.Text = "";
            txbValue.Focus();
            ShowDialog();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (TryConfirm(txbValue.Text)) Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void txbValue_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter) btnOK_Click(null, null);
            if (e.KeyCode == Keys.Cancel) btnCancel_Click(null, null);
        }
    }
}
